package com.kis.service

import com.alibaba.fastjson.JSON
import com.kis.dao.OrderDao
import com.kis.model.Order
import com.kis.model.ResponseData
import com.kis.model.user.User
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

/**
 * Created by wongloong on 16-12-8.
 */
@Service("orderService")
class OrderService {
    @Autowired
    lateinit var orderDao: OrderDao
    @Autowired
    lateinit var userClient: UserClient

    fun saveOrUpdate(order: Order): ResponseData {
        var u = User()
        u.username="create in order"
        u.password="password"
        u.realName="test in actions"
        val result = userClient.saveOrUpdateUser(JSON.toJSONString(u))
        if (result.success) {
            return ResponseData(orderDao.save(order) != null)
        } else {
            return ResponseData(false)
        }
    }
}